class Persons{
    String name;
    int age;

    public void study(){
        System.out.println(this.name + "在学习");
    }
}

class Student extends Persons{

    public void play(){
        System.out.println(this.name + "在玩");
    }

}

class Teacher extends Persons{
    public void talk(){
        System.out.println(this.name + "在交谈");
    }
}


public class Blog03 {


    public static Persons func2(){
        return new Student();
    }

    //2.
    public static void func(Persons persons){

    }

    public static void main(String[] args) {
        //向上转型的几种形式

        //1.直接赋值
        //  形式一
        Persons persons = new Student();
        //  形式二
        Student student = new Student();
        Persons persons1 = student;

        //2.方法传参
//        public static void func(Persons persons){
//
//        }
        func(new Student());
        //也等价于 Student student = new Student();
        //        func(student);



//        也是相当于 Persons persons = new Student();



        //3.作为返回值
//        public static Persons func2(){
//            return new Student();
//        }

    }

}
